{// 引入标签库 }
<tagLib name="html" />
<include file="Public:header" />
<PHP>
	function get_handle($id)
	{
		$order_info = M("DealOrder")->getById($id);
		if($order_info['order_status']==0)
		{
			$str = l("DEAL_ORDER_HANDLE");
		}
		else
		{
			$str = l("DEAL_ORDER_VIEW");
		}
		$str = "<a href='".u("DealOrder/view_order",array("id"=>$id))."'>".$str."</a>";
		if($order_info['order_status']==1)
		{
			$str.="&nbsp;&nbsp;<a href='javascript:del(".$id.");'>".l("DEL")."</a>";
		}
		return $str;
	}
	function get_extra_status($status)
	{
		return l("EXTRA_STATUS_".$status);
	}
	function get_after_sale($status,$order_status)
	{
		if($order_status==0)
		return l("NO_OVER_ORDER");
		else
		return l("AFTER_SALE_".$status);
	}
	
	function get_order_item($order_sn,$order_id)
	{
		$deal_order_item = M("DealOrderItem")->where("order_id = ".$order_id)->findAll();
		$str = "<span style='font-size:14px; font-family:verdana; font-weight:bold;'>".$order_sn."</span>";
		foreach($deal_order_item as $v)
		{
			$str.="<br />&nbsp;".l('DEAL_ID').":".$v['deal_id']."&nbsp;<span title='".$v['name']."'";
			if(intval($_REQUEST['deal_id'])==$v['deal_id'])
			{
				$str.=" style='color:red;' ";
			}
			$str.=">".msubstr($v['name'],0,5)."</span>&nbsp;".l("NUMBER")." [".$v['number']."]";
		}
		
		return $str;
		
	}
	function get_refund_status($s)
	{
		if($s==0)
		return "无";
		if($s==1)
		return "<span style='color:#f30;'>要求退款</span>";
		if($s==2)
		return "已处理";
	}
	function get_retake_status($s)
	{
		if($s==0)
		return "无";
		if($s==1)
		return "<span style='color:#f30;'>要求退货</span>";
		if($s==2)
		return "已处理";
	}
</php>
<load href='__TMPL__Common/js/jquery.bgiframe.js' />
<load href='__TMPL__Common/js/jquery.weebox.js' />
<load href='__TMPL__Common/style/weebox.css' />
<script type="text/javascript">
	function batch_delivery()
	{
		express_id = $("select[name='express_id']").val();
		if(express_id==0)
		{
			alert(LANG['SELECT_EXPRESS_WARNING']);
			return;
		}
		idBox = $(".key:checked");
		if(idBox.length == 0)
		{
			alert(LANG['SELECT_EMPTY_WARNING']);
			return;
		}
		idArray = new Array();
		$.each( idBox, function(i, n){
			idArray.push($(n).val());
		});
		ids = idArray.join(",");
		
		$.weeboxs.open(ROOT+'?m=DealOrder&a=load_batch_delivery&ids='+ids+"&express_id="+express_id, {contentType:'ajax',showButton:false,title:LANG['BATCH_DELIVERY'],width:600,height:120});
	}
	
	function batch_print()
	{
		express_id = $("select[name='express_id']").val();
		if(express_id==0)
		{
			alert(LANG['SELECT_EXPRESS_WARNING']);
			return;
		}
		idBox = $(".key:checked");
		if(idBox.length == 0)
		{
			alert(LANG['SELECT_EMPTY_WARNING']);
			return;
		}
		idArray = new Array();
		$.each( idBox, function(i, n){
			idArray.push($(n).val());
		});
		ids = idArray.join(",");
		window.open(ROOT+'?m=Express&a=eprint&order_id='+ids+"&express_id="+express_id);
	}
</script>
<div class="main">
<div class="main_title">{%DEAL_ORDER}</div>
<div class="blank5"></div>
<form name="search" action="__APP__" method="get">	
<div class="button_row">
	<input type="button" class="button" value="{%DEL}" onclick="del();" />
	<input type="submit" class="button" value="{%SEARCH}" />
	<if condition="!$_REQUEST['referer']">
	<input type="button" class="button" value="{%EXPORT}" onclick="export_csv();" />
	</if>
	<input type="button" class="button" value="{%BATCH_DELIVERY}" onclick="batch_delivery();" />
	<input type="button" class="button" value="{%BATCH_PRINT}" onclick="batch_print();" />
	
	<lable>{%SELECT_EXPRESS}
		<select name="express_id">
			<option value="0">{%OTHER_EXPRESS}</option>
			<foreach name="express_list" item="express">
				<option value="{$express.id}">{$express.name}</option>
			</foreach>
		</select>
	</lable>
</div>
<div class="blank5"></div>
<div class="search_row">

		{%ORDER_SN}：<input type="text" class="textbox" name="order_sn" value="{:trim($_REQUEST['order_sn'])}" style="width:100px;" />
		{%DEAL_ID}：<input type="text" class="textbox" name="deal_id" value="{:trim($_REQUEST['deal_id'])}" style="width:30px;" />
		{%USER_NAME_S}：<input type="text" class="textbox" name="user_name" value="{:trim($_REQUEST['user_name'])}" style="width:100px;" />

		{%PAYMENT_STATUS_S}: 
		<select name="pay_status">
				<option value="-1" <if condition="intval($_REQUEST['pay_status']) eq -1">selected="selected"</if>>{%ALL}</option>
				<option value="0" <if condition="intval($_REQUEST['pay_status']) eq 0">selected="selected"</if>>{%PAY_STATUS_0}</option>
				<option value="1" <if condition="intval($_REQUEST['pay_status']) eq 1">selected="selected"</if>>{%PAY_STATUS_1}</option>
				<option value="2" <if condition="intval($_REQUEST['pay_status']) eq 2">selected="selected"</if>>{%PAY_STATUS_2}</option>			
		</select>
		{%DELIVERY_STATUS_S}: 
		<select name="delivery_status">
				<option value="-1" <if condition="intval($_REQUEST['delivery_status']) eq -1">selected="selected"</if>>{%ALL}</option>
				<option value="0" <if condition="intval($_REQUEST['delivery_status']) eq 0">selected="selected"</if>>{%ORDER_DELIVERY_STATUS_0}</option>
				<option value="1" <if condition="intval($_REQUEST['delivery_status']) eq 1">selected="selected"</if>>{%ORDER_DELIVERY_STATUS_1}</option>
				<option value="2" <if condition="intval($_REQUEST['delivery_status']) eq 2">selected="selected"</if>>{%ORDER_DELIVERY_STATUS_2}</option>
				<option value="5" <if condition="intval($_REQUEST['delivery_status']) eq 5">selected="selected"</if>>{%ORDER_DELIVERY_STATUS_5}</option>			
		</select>
		{%EXTRA_STATUS_S}: 
		<select name="extra_status">
				<option value="-1" <if condition="intval($_REQUEST['extra_status']) eq -1">selected="selected"</if>>{%ALL}</option>
				<option value="0" <if condition="intval($_REQUEST['extra_status']) eq 0">selected="selected"</if>>{%EXTRA_STATUS_0}</option>
				<option value="1" <if condition="intval($_REQUEST['extra_status']) eq 1">selected="selected"</if>>{%EXTRA_STATUS_1}</option>
				<option value="2" <if condition="intval($_REQUEST['extra_status']) eq 2">selected="selected"</if>>{%EXTRA_STATUS_2}</option>
		</select>
		{%AFTER_SALE_S}: 
		<select name="after_sale">
				<option value="-1" <if condition="intval($_REQUEST['after_sale']) eq -1">selected="selected"</if>>{%ALL}</option>
				<option value="0" <if condition="intval($_REQUEST['after_sale']) eq 0">selected="selected"</if>>{%AFTER_SALE_0}</option>
				<option value="1" <if condition="intval($_REQUEST['after_sale']) eq 1">selected="selected"</if>>{%AFTER_SALE_1}</option>
				<option value="2" <if condition="intval($_REQUEST['after_sale']) eq 2">selected="selected"</if>>{%AFTER_SALE_2}</option>
				<option value="3" <if condition="intval($_REQUEST['after_sale']) eq 3">selected="selected"</if>>{%AFTER_SALE_3}</option>
		</select>

		<input type="hidden" value="DealOrder" name="m" />
		<input type="hidden" value="deal_index" name="a" />
		

</div>
</form>
<div class="blank5"></div>
<html:list 
	id="dataTable" 
	style="dataTable" 
	name="deal_order" 
	checkbox="true" 
	action="true" 
	datasource="list" 
	show="id:{%ID}|50px,order_sn|get_order_item=$deal_order['id']:{%ORDER_SN},user_id|get_user_name:{%USER_NAME},total_price|format_price:{%PAY_AMOUNT},pay_amount|format_price:{%PAID_AMOUNT}
		 ,refund_status|get_refund_status:退款申请
		 ,retake_status|get_retake_status:退货申请
		 ,create_time|to_date:{%ORDER_CREATE_TIME},pay_status|get_pay_status:{%PAYMENT_STATUS},delivery_status|get_delivery_status=$deal_order['id']:{%DELIVERY_STATUS}
		 ,extra_status|get_extra_status:{%EXTRA_STATUS}
		 ,after_sale|get_after_sale=$deal_order['order_status']:{%AFTER_SALE}" 
	actionlist="id|get_handle" /> 

<div class="blank5"></div>
<div class="page">{$page}</div>
</div>
<include file="Public:footer" />